package com.evan.common.core.constant;

public enum SubjectLevelEnum {
    NONE(0, "无等级"),
    PRIMARY(1, "初级"),
    MIDDLE(2, "中级"),
    SENIOR(3, "高级");

    private int code;
    private String name;

    SubjectLevelEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static SubjectLevelEnum getByCode(int code) {
        for (SubjectLevelEnum subjectTypeEnum : values()) {
            if (subjectTypeEnum.getCode() == code) {
                return subjectTypeEnum;
            }
        }
        return null;
    }

    public static SubjectLevelEnum getByName(String name) {
        for (SubjectLevelEnum subjectTypeEnum : values()) {
            if (subjectTypeEnum.getName().equals(name)) {
                return subjectTypeEnum;
            }
        }
        return null;
    }
}
